
<template>
  <view class="agency">
    <!-- <hunk-head name="马上安家"></hunk-head> -->
    <!-- <div class="agency-list"> -->
      <scroll-view
        class="agency-list"
        scroll-y="true"
        @scrolltolower="_onLoadmore"
      >
        <div class="agency-item" v-for="(item,index) in todolist" :key="index">
          <div class="top">
            <div class="text">{{item.title}}</div>
            <div class="btn" v-if="!item.state">
              <button @click="aggree(2,item)">拒绝</button>
              <button @click="aggree(1,item)">同意</button>
            </div>
          </div>
          <div class="item-centent">
            <div class="text-list">
              <span>发起人姓名：</span>
              {{item.unickname}}
            </div>
            <div class="text-list">
              <span>发起人身份证号：</span>
              {{item.cardid}}
            </div>
            <div class="text-list">
              <span>房屋地址：</span>
              {{item.communityname}}
            </div>
            <div class="text-list">
              <span>时  间：</span>
              {{item.starttime}}
            </div>
            <div class="text-list status" :style="{color: item.state == 2 ? '#FF6B75': (item.state == 1 ? '#12CB6E' : '#FC913A')}">
              <span>待办事项状态：</span>
              {{item.state == 2 ? '已拒绝': (item.state == 1 ? '已同意' : '待审批')}}
            </div>
          </div>
        </div>
        <!-- <div class="agency-item">
          <div class="top">
            <div class="text">线下下单</div>
            <div class="btn">
              <button>拒绝</button>
              <button>同意</button>
            </div>
          </div>
          <div class="item-centent">
            <div class="text-list">
              <span>发起人姓名：</span>
              李三
            </div>
            <div class="text-list">
              <span>发起人身份证号：</span>
              320324199603
            </div>
            <div class="text-list">
              <span>房屋地址：</span>
              天星美和园公寓3栋-二单元-3
            </div>
            <div class="text-list">
              <span>时  间：</span>
              2021/03/12 11:12
            </div>
            <div class="text-list status" style="color:#FC913A">
              <span>待办事项状态：</span>
              待审批
            </div>
          </div>
        </div>
        <div class="agency-item">
          <div class="top">
            <div class="text">预约看房</div>
            <div class="btn">
              <button>拒绝</button>
              <button>同意</button>
            </div>
          </div>
          <div class="item-centent">
            <div class="text-list">
              <span>发起人姓名：</span>
              李三
            </div>
            <div class="text-list">
              <span>发起人身份证号：</span>
              320324199603
            </div>
            <div class="text-list">
              <span>房屋地址：</span>
              天星美和园公寓3栋-二单元-3
            </div>
            <div class="text-list">
              <span>时  间：</span>
              2021/03/12 11:12
            </div>
            <div class="text-list status" style="">
              <span>待办事项状态：</span>
              已拒绝
            </div>
          </div>
        </div> -->
      </scroll-view>
    <!-- </div> -->
    <div v-if=" isnone < 1" class="none">
      <!-- <img :src="baseUrl+'none.jpeg'" alt=""> -->
      <img v-if="baseUrl" :src="baseUrl+'imgs/imgs/none.png'" alt="">
      <!-- <div>暂无数据</div> -->
    </div>
  </view>
</template>

<script>
import {getTodolist,agreeTodolist} from '@/apis/agency'
export default {
  data() {
    return {
      title: 'Hello',
      listInfo: {
        limit: '10',
        offset: '1',
        type: "1"
      },
      todolist: [
      ]
    }
  },
  computed: {
    userid(){
      return this.$store.state.baseStore.userInfo.userid
    },
    isnone(){
       if(this.todolist){
         return this.todolist.length
       }else{
         return false
       }
    },
    baseUrl() {
      return process.env.VUE_APP_BASE_IMG_URL;
    }
  },
  // onshow(){
  //   this.listInfo.offset = 1
  //   this.getTodolist()
  // },
  created(){
    this.listInfo.offset = 1
    this.getTodolist()
  },
  methods: {
    getTodolist(){
      getTodolist({...this.listInfo,userid:this.userid}).then(res=>{
        if( res.code == 200){
          if (this.listInfo.offset === 1) {
            this.todolist = res.data
          }else if(this.todolist.length >= res.total){
            return
          } else {
            this.todolist = this.todolist.concat(res.data)
          }
        }
      })
    },
    _onLoadmore(){
      console.log(9999)
      ++this.listInfo.offset
      this.getTodolist()
    },
    aggree(int,item){
      let that = this
      agreeTodolist({type:int,wid: item.wid}).then(res=>{
        if(res.code == 200){
          that.listInfo.offset = 1
          that.getTodolist()
          uni.showToast({
            title: '操作成功',
            icon: 'none'
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.agency{
  // @include num();
  // min-height: calc(100vh - 50px);
  box-sizing: border-box;
  height: 100%;
  // flex: 1;
  display: flex;
  .agency-list{
    flex: 1;
    .agency-item{
      background-color: #fff;
      margin-bottom: 10px;
      .top{
        height: 36px;
        padding: 0 15px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 2px solid #EFEFEF;
        .text{
          font-size: 14px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #000000;
          line-height: 36px;
        }
        .btn{
          display: flex;
          button{
            border: 0;
            width: 60px;
            height: 24px;
            background: linear-gradient(315deg, #FFAA58 0%, #FFBD6C 100%);
            border-radius: 13px;
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #FFFFFF;
            line-height: 24px;
            &:first-child{
              margin-right: 5px;
            }
          }
          button::after{
            border: 0;
          }
        }
      }
      .item-centent{
        padding: 10px 10px 10px 10px;
        .text-list{
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #4A4A4A;
          line-height: 20px;
          margin-bottom: 10px;
          span{
            color: #9B9B9B;
          }
        }
        .status{
          color: #12CB6E;
          span{
            color: #9B9B9B;
          }
        }
      }
    }
  }
  .none{
    width: 100vw;
    height: 100%;
    // background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    img{
      width: 190px;
      height: 195px;
    }
  }
}

</style>
